package com.company.tencent2020;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String res = unzipString(s);
        System.out.println(res);

    }

    private static String unzipString(String s) {
        if(s == null || s.length() == 0 || s == ""){
            return s;
        }
        Stack<Character> stack = new Stack<>();
        int len = s.length();
        boolean hasUp = false;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if(c == '['){
               // 栈中有[ 说明有嵌套
                if(hasUp){
                    stack.push(c);
                }
            }
            if(c != ']'){
                stack.push(c);
            }else{
                // 得到|后的字符串
                List<Character> list = new ArrayList<>();
                while (!stack.isEmpty()){
                    if(stack.peek() != '|'){
                        list.add(0,stack.pop());
                    }else{
                        break;
                    }
                }
                // 获取个数
                int count = 0;
                stack.pop();
                char t = stack.pop();
                count = t - '0';
                // 删除'['
                stack.pop();
                // 添加到栈中
                for (int j = 0; j < count; j++) {
                    for (int k = 0; k < list.size() ; k++) {
                        stack.push(list.get(k));
                    }
                }
            }
        }

        int size = stack.size();
        char[] res = new char[size];
        int pos = size - 1;
        while (!stack.isEmpty()){
            res[pos--] = stack.pop();
        }
        return new String(res,0,size);
    }
}
